<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<link rel="stylesheet" href="${staticServer}/inc/style/main.css"/>
	<link rel="stylesheet" href="${staticServer}/inc/style/page.css"/>
	<link rel="stylesheet" href="${staticServer}/css/consultant_client.css"/>
	<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
	
	<script src="${staticServer}/inc/js/jquery.js"></script>
	<script src="${staticServer}/inc/js/core/page_core.js"></script>
	<script src="${staticServer}/inc/js/core/utils.js"></script>
	<script src="${staticServer}/inc/js/pageset.js"></script>
	<script src="${staticServer}/inc/js/submitter.js"></script>
	<script src="${staticServer}/inc/js/datepicker.js"></script>
	<script src="${staticServer}/inc/js/htmlfilter.js"></script>
	<script src="${staticServer}/inc/js/tips.js"></script>
	<script src="${staticServer}/inc/js/system/system_client_temp.js?1.0"></script>
	
<script>
$( "body" ).ready( function( e ){
	select_date( 'datetime', dateSelected );
});

function select_date( targetid, func ){
	$( '#' + targetid ).Zebra_DatePicker( { format: 'Y-m-d', show_icon: false, onSelect: func } );
}
	
function cdatetime( flag ){	
	var day_stamp=$("#datetime").val();
	var tea_name = $("#tea_name").val();
	var center = $("#center").val();
	var ds = day_stamp.split("-");
	var d = new Date();
	d.setFullYear( parseInt( ds[ 0 ] ), parseInt( ds[ 1 ] ) - 1, parseInt( ds[ 2 ] ) );
	
	var week = d.getDay();
	var ms = d.getTime();
	var kd = 0;

	week = week == 0 ? 7 : week;

	if( flag == -1 )
	{
		kd = week * -1;
		d.setTime( ms + kd * 86400000 );
	}
	else if( flag == 1 )
	{
		kd = 8 - week;
		d.setTime( ms + kd * 86400000 );
	}
	else if( flag == 2 )
	{
		window.location.reload();
		return;
	}
	else
	{
		kd = 0;
		d = new Date();
	}
	var datetime = (d.getFullYear() + "-" + ( d.getMonth() + 1 ) + "-" + d.getDate());
	var region = $("#region").val();
	location.href = "?datetime=" + datetime+"&tea_name="+tea_name+"&center="+center;
}

function dateSelected( val, date ){
	var datetime = $("#datetime").val();
	var tea_name = $("#tea_name").val();
	var center = $("#center").val();
	location.href = "?datetime=" + datetime+"&tea_name="+tea_name+"&center="+center;
}
$(function(){
	$("#center").val("<#if center??>${center}</#if>");
	$("#tea_name").val("<#if tea_name??>${tea_name}</#if>");
	
	$("#center").change(function(){
		var keyname = $("#center").val();
		$.post("${contextPath}/index/getTeacherBycenter.json", {
			"keyname":keyname
		}, function(ms) {
			var list = ms.userlist;
			var objHtml="<option >--请选择咨询老师--</option>";
			if(list!=null){
		    	for(var i=0;i<list.length;i++){
		    		objHtml +='<option value="'+list[i].username+'">'+list[i].nickname+'</option>';
		    	}
		    	$("#tea_name").html(objHtml);
			 }
		});
	});	
	$("#tea_name").change(function(){
		var tea_name = $("#tea_name").val();
		var center = $("#center").val();
		var datetime = $("#datetime").val();
		if(tea_name!=""){
			location.href = "${contextPath}/index/consultant_personal_today_allot.htm?tea_name="+tea_name+"&datetime="+datetime+"&center="+center;
		}
	});	
});


	</script>
</head>

<body>
	<div id="home_link">
		<ul>
			<li>竞思教育网络办公系统 v2.0 beta</li>
			<li>&gt;</li>
			<li>咨询师业务统计</li>
			<li>&gt;</li>
			<li class="current">当日跟踪客户统计</li>
		</ul>
	</div>
	<div id="container">
		<div id="title"></div>
		   <table class="form_table"><tr>
				<td>
					<label><b>所属中心：</b></label>
					<select id="center">
						<option value="">请选择中心</option>
						<#if offList??>
							<#list offList as list>
								<option value="${list.keyname}">${list.name}</option>
							</#list>
						</#if>
					</select>
					<select id="tea_name">
						<option value="">--请选择咨询老师--</option>
						<#if userlist??>
							<#list userlist as list>
								<option value="${list.username}">${list.nickname}</option>
							</#list>
						</#if>
				</select>
				</td>
				<td><label><b>更换日期：</b></label>
						<input type="text" readyonly="true" id="datetime" value="${newday}" size="20" maxlength="20" rel="DATE::Y-m-d" >
	                    <input type="button" value=" 刷新 " onclick="cdatetime(2)" />
	                    <input type="button" value=" 上一周 " onclick="cdatetime(-1)" />
	                    <input type="button" value=" 下一周 " onclick="cdatetime(1)" />
	                    <input type="button" value=" 最近一周 " onclick="cdatetime(0)" />
                 </td>
			</tr>
		</table>
		
		<table id="tbl_client">
			<tr class="fields">
				<th colspan="2">当周跟踪客户统计</th>
			</tr>
			<tr>
				<th width="25%">星期一跟踪客户数量（${BeforetwoDay}）</th>
				<td width="75%" id="txtTotal">${list1[0]}</td>
			</tr>
			<tr>
				<th width="25%">星期二跟踪客户数量（${BeforeDay}）</th>
				<td width="75%" id="txtTotal">${list1[1]}</td>
			</tr>
			
			<tr>
				<th width="25%">星期三跟踪客户数量（${today}）</th>
				<td width="75%" id="txtTotal">${list1[2]}</td>
			</tr>
			<tr>
				<th width="25%">星期四跟踪客户数量（${tommorrow1}）</th>
				<td width="75%" id="txtTotal">${list1[3]}</td>
			</tr>
			<tr>
				<th width="25%">星期五跟踪客户数量（${tommorrow2}）</th>
				<td width="75%" id="txtTotal">${list1[4]}</td>
			</tr>
			<tr>
				<th width="25%">星期六跟踪客户数量（${tommorrow3}）</th>
				<td width="75%" id="txtTotal">${list1[5]}</td>
			</tr>
			<tr>
				<th width="25%">星期天跟踪客户数量（${tommorrow4}）</th>
				<td width="75%" id="txtTotal">${list1[6]}</td>
			</tr>
		</table>
	</div>
</body>
</html>